package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.AtWho;
import cn.wolfcode.trip.base.domain.Commentait;
import cn.wolfcode.trip.base.mapper.AtWhoMapper;
import cn.wolfcode.trip.base.mapper.CommentaitMapper;
import cn.wolfcode.trip.base.service.IAtWhoService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AtWhoServiceImpl implements IAtWhoService {
    @Autowired
    private AtWhoMapper mapper;

    @Autowired
    private CommentaitMapper commentaitMapper;


    @Override
    public void saveAt(AtWho a) {
        mapper.insert(a);
    }

    @Override
    public int countAtWho(Long id) {
        return mapper.countNum(id);
    }

    @Override
    public int countAtComment(Long id) {
        return mapper.countComment(id);
    }

    @Override
    public PageInfo selectAllNoReadAt(Long id) {
        //设置按照加入的倒序显示
        PageHelper.startPage(1, 30, "id desc");
        List<AtWho> list = mapper.selectAllNoReadAt(id);
        return new PageInfo(list);
    }

    @Override
    public void read(Long id) {
        mapper.read(id);
    }

    @Override
    public PageInfo listAllNoReadCommend(Long id) {
        PageHelper.startPage(1, 30,"id desc");
        List<Commentait> list = commentaitMapper.listAllNoReadCommend(id);
        return new PageInfo(list);
    }

    @Override
    public void readComment(Long id) {
        mapper.readComment(id);
    }
}
